const admin = require('../models/admin');
const jwt = require('jsonwebtoken');

let login = async (body, res) => {
	await admin
		.findOne({
			where: { username: body.username, password: body.password }
		})
		.then(result => {
			let content = { username: body.username };
			let token = jwt.sign(content, 'jares', {
				expiresIn: 60 * 60 * 1
			});
			res.json({
				code: 0,
				data: token,
				msg: 'success'
			});
		});
};

module.exports = {
	login
};
